import Taro, { Component, Config } from '@tarojs/taro'
import { View } from '@tarojs/components'
import { AtTabBar } from "taro-ui";
import './index.scss'
import Home from "./components/home"; //首页
import User from "./components/user"; //我的

// import Login from '../../components/login/index';

export default class Index extends Component {

  /**
   * 指定config的类型声明为: Taro.Config
   *
   * 由于 typescript 对于 object 类型推导只能推出 Key 的基本类型
   * 对于像 navigationBarTextStyle: 'black' 这样的推导出的类型是 string
   * 提示和声明 navigationBarTextStyle: 'black' | 'white' 类型冲突, 需要显示声明类型
   */
  config: Config = {
    navigationBarTitleText: '小程序',
  }
  state = {
    current: 0,
  }
  componentWillMount () { }

  componentDidMount () { }

  componentWillUnmount () { }

  componentDidShow () { }

  componentDidHide () { }
  handleClick (value) {
    this.setState({
      current: value
    })
  }
  render () {
    let current = this.state.current;
    return (
      <View className='index'>
        {/*<Login/>*/}
        {
          current === 0?<Home/>:<User/>
        }
        <AtTabBar
          fixed={true}
          tabList={[
            { title: '首页',iconType:'home'},
            { title: '我的',iconType:'user'},
          ]}
          onClick={this.handleClick.bind(this)}
          current={this.state.current}
        />
      </View>
    )
  }
}
